package com.sicheng.lc.周赛.分类.贪心;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/7/2 22:42
 */
public class 同时运行N台电脑的最长时间 {
    //todo
    //https://leetcode.cn/problems/maximum-running-time-of-n-computers/
    public long maxRunTime(int n, int[] batteries) {
        if (n > batteries.length)
            return 0;
        int min = (int) (1e9 + 7);
        long sum = 0;
        for (int battery : batteries) {
            min = Math.min(battery, min);
            sum += battery;
        }
        return (sum - (long) n * min) / n + min;


    }
}
